#ifndef STACK_H_INCLUDED
#define STACK_H_INCLUDED
#include <iostream>
#include <vector>

using namespace std;

typedef int ele_type;

class Stack {
    public:
        Stack() {
            ele_top = -1;
            }
        ~Stack() {}
        void push(ele_type x) {
            data.emplace_back(x);
            ele_top++;
            }
        ele_type pop() {
            if (ele_top == -1) {
                cout << "栈为空" << endl;
                system("pause");
                }
                ele_type x = data[data.size() - 1];
                data.pop_back();
                ele_top--;
                return x;
            }
        ele_type top() {
            if (ele_top == -1) {
                cout << "栈为空" << endl;
                system("pause");
                }
                ele_type x = data[data.size() - 1];
                return x;
            }
        bool empty() {
            return ele_top == -1 ? true : false;
        }
        void print() {
            if (ele_top == -1) {
                cout << "栈为空" << endl;
                return;
                }
            ele_type n = ele_top;
            while(n) {
                cout << data[n--] << endl;
            }
        }
        vector<ele_type> data;
        int ele_top;
    };


#endif // STACK_H_INCLUDED
